<#include "_layout.html" />
<@layout>

    <script language="javascript" type="text/javascript">
    $(document).ready(function(){
        document.onkeydown=nextpage
        document.onkeydown=nextpage
        var prevpage="contest/status/${cid!}?p=${solutionList.pageNumber-1}<#if solutionList.pageSize!=20>&s=${solutionList.pageSize}</#if>"
        var nextpage="contest/status/${cid!}?p=${solutionList.pageNumber+1}<#if solutionList.pageSize!=20>&s=${solutionList.pageSize}</#if>"
        function nextpage(event)
        {
            event=event?event:(window.event?window.event:null);
            <#if solutionList.pageNumber&gt;1>if(event.keyCode==37)location=prevpage;</#if>
            <#if solutionList.pageNumber<solutionList.totalPage>if(event.keyCode==39)location=nextpage;</#if>
        }
        });
    </script>

    <div class="pagination pagination-centered">
        <div class="form-inline">
        <form class="form-search" action="contest/status/${cid!}">
            <input type="text" class="input-small" name="id" value="${id!}" placeholder="Problem ID">
            <input type="text" class="input-small" name="name" value="${name!}" placeholder="User Name">
            <select class="input-small" id="inputResult" name="result">
                <option value="-1">Result</option>
                <#if judge_result??>
                <#list judge_result as Result>
                <option value="${Result.id!}" <#if result?? && result?eval==Result.id>selected</#if>>${Result.name!}</option>
                </#list>
                </#if>
            </select>
            <select class="input-medium" id="inputLanguage" name="language">
                <option value="-1">Language</option>
                <#if program_languages??>
                <#list program_languages as Language>
                <option value="${Language.id!}" <#if language?? && language==Language.id>selected</#if>>${Language.name!}</option>
                </#list>
                </#if>
            </select>
            <button type="submit" class="btn">Go</button>
        </form>
        </div>
        
        <div class="pull-right">
            <span class="badge badge-info">${solutionList.pageNumber}/${solutionList.totalPage} Pages</span>
            <span class="badge badge-info">${solutionList.totalRow} Records</span>
        </div>
    </div>
   
    <table id="status" class="table table-hover table-condensed">
        <thead>
          <tr>
            <th>Run ID</th>
            <th>User</th>
            <th>Problem</th>
            <th>Result</th>
            <th>Time</th>
            <th>Memory</th>
            <th>Language</th>
            <th>Code Length</th>
            <th>Submit Time</th>
          </tr>
        </thead>
        <tbody>
        <#if solutionList??>
        <#list solutionList.list as solution>
        <tr>
            <td class="sid">${solution.sid!}</td>
            <td class="user"><a href="user/profile/${(solution.name)!}" data-toggle="tooltip" title="${(solution.nick)!}">${(solution.name)!}</a></td>
            <td class="problem"><a href="contest/problem/${cid}-${solution.alpha!}">${cid}-${solution.alpha!}</a></td>
            <td class="result" id="${solution.resultName!}">${solution.resultLongName!}</td>
            <td class="time"><#if solution.result==0>${solution.time!0} MS</#if></td>
            <td class="memory"><#if solution.result==0>${solution.memory!0} KB</#if></td>
            <td class="language">
                <#if userID?? &&(adminUser?? || userID==solution.uid)><a href="code/${solution.sid!}?cid=${cid}" target="blank" title="show source code"></#if>
                ${solution.language!}
                <#if userID?? &&(adminUser?? || userID==solution.uid)></a></#if>
            </td>
            <td class="code_len">${solution.code_len!}B</td>
            <td class="ctime">${solution.ctime!}</td>
        </tr>
        </#list>
        </#if>
        </tbody>
    </table>
    <div class="pagination pagination-centered">
    <ul>
        <li class="<#if solutionList.pageNumber==1>disabled</#if>"><a href="contest/status/${cid!}?p=1<#if solutionList.pageSize!=20>&s=${solutionList.pageSize}</#if><#if query??>${query}</#if>">&lt;&lt;</a></li>
        <#if solutionList.pageNumber&gt;1><li><a href="contest/status/${cid!}?p=${solutionList.pageNumber-1}<#if solutionList.pageSize!=20>&s=${solutionList.pageSize}</#if><#if query??>${query}</#if>">Prev</a></li></#if>
        <#if solutionList??>
        <#assign start=solutionList.pageNumber-3>
        <#assign end=solutionList.pageNumber+3>
        <#if start<1><#assign end=end-start+1><#assign start=1></#if>
        <#if end&gt;solutionList.totalPage ><#assign start=start-(end-solutionList.totalPage)-1><#if start<1><#assign start=1></#if><#assign end=solutionList.totalPage></#if>
        <#if end<start><#assign end=start></#if>
            <#list start..end as x>
            <li class="<#if x==solutionList.pageNumber>active</#if>"><a href="contest/status/${cid!}?p=${x}<#if solutionList.pageSize!=20>&s=${solutionList.pageSize}</#if><#if query??>${query}</#if>">${x}</a></li>
            </#list>
        </#if>
        <#if solutionList.pageNumber<solutionList.totalPage><li><a href="contest/status/${cid!}?p=${solutionList.pageNumber+1}<#if solutionList.pageSize!=20>&s=${solutionList.pageSize}</#if><#if query??>${query}</#if>">Next</a></li></#if>
        <li class="<#if solutionList.pageNumber&gt;=solutionList.totalPage>disabled</#if>"><a href="contest/status/${cid!}?p=${solutionList.totalPage}<#if solutionList.pageSize!=20>&s=${solutionList.pageSize}</#if><#if query??>${query}</#if>">&gt;&gt;</a></li>
        </ul>
    </div>
    <script type="text/javascript" src="assets/js/placeholder.js"></script>

</@layout>